Skip to content

fix: use PKCS#8 for key serialization and verify PQC TLS 1.3 support - #1501

Merged
panavenue merged 2 commits into
mainfrom
pqc-python-connector
Nov 11, 2026
Merged

panavenue merged 2 commits into
mainfrom
pqc-python-connector

Conversation

@panavenue

Copy link
Copy Markdown
Contributor

Summary

Aligns key serialization with GoogleCloudPlatform/alloydb-python-connector#547, verifies and continuously tests hybrid Post-Quantum Cryptography (PQC) TLS 1.3 key exchange (X25519MLKEM768) on OpenSSL 3.5+, and documents PQC runtime requirements in README.md.

ConnectionInfo.create_ssl_context() already enforces ssl.TLSVersion.TLSv1_3 (when supported by OpenSSL) without restricting key-exchange groups, so Python runtimes linked against OpenSSL 3.5+ automatically offer and negotiate X25519MLKEM768 (0x11ec).

Changes

  • google/cloud/sql/connector/utils.py & tests/: Switch generate_keys() private key serialization from legacy PKCS#1 (TraditionalOpenSSL) to modern algorithm-agnostic PKCS8 (-----BEGIN PRIVATE KEY-----), matching GoogleCloudPlatform/alloydb-python-connector#547, while preserving full backwards compatibility with existing RSA keys and SSLContext.load_cert_chain. Update tests/conftest.py and tests/unit/mocks.py (CertificatePublicKeyTypes) accordingly.
  • tests/unit/test_pqc.py & tests/unit/test_utils.py:
    • Verify generate_keys() emits PKCS#8 private keys and SubjectPublicKeyInfo public keys.
    • Verify ConnectionInfo.create_ssl_context() completes real TLS 1.3 mTLS handshakes with modern PKCS#8 RSA keys, legacy PKCS#1 RSA keys, and ECDSA PKCS#8 keys.
    • Verify real TLS 1.3 mTLS handshakes advertise and negotiate X25519MLKEM768 (0x11ec) by default on OpenSSL 3.5+, fall back cleanly to classical ECDHE (secp256r1 / 0x0017 via HelloRetryRequest) against classical-only servers, and honor client-side OPENSSL_CONF Groups opt-out.
  • .github/workflows/tests.yml: Add unit-pqc CI job running nox -s unit-3.13 inside a digest-pinned python:3.13-trixie container (OpenSSL 3.5+), since ubuntu-latest (24.04) ships OpenSSL 3.0.x.
  • README.md: Add a Post-Quantum Cryptography (PQC) section covering automatic X25519MLKEM768 negotiation on OpenSSL 3.5+, checking ssl.OPENSSL_VERSION, classical fallback compatibility, and OPENSSL_CONF opt-out caveats.

@panavenue
panavenue marked this pull request as ready for review November 2, 2026 20:48
@panavenue
panavenue requested a review from a team as a code owner November 2, 2026 20:48
@panavenue
panavenue requested a review from enocom November 3, 2026 19:17
@panavenue
panavenue force-pushed the pqc-python-connector branch from 3615c8f to 9b68c4e Compare November 11, 2026 01:30
@panavenue
panavenue merged commit e1c7228 into main Nov 11, 2026
28 of 30 checks passed
@panavenue
panavenue deleted the pqc-python-connector branch November 11, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants